package com.party.core.service.charge.impl;

import com.party.common.paging.Page;
import com.party.common.utils.StringUtils;
import com.party.core.dao.read.charge.RemittanceVoucherReadDao;
import com.party.core.dao.write.charge.RemittanceVoucherWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.charge.RemittanceVoucher;
import com.party.core.service.charge.IRemittanceVoucherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * @program: party
 * @description: 汇款凭证業務
 * @author: Hua Qunhao
 * @create: 2019-05-21 11:16
 **/
@Service("RemittanceVoucherService")
public class RemittanceVoucherService implements IRemittanceVoucherService{
    @Autowired
    private RemittanceVoucherReadDao remittanceVoucherReadDao;
    @Autowired
    private RemittanceVoucherWriteDao remittanceVoucherWriteDao;

    @Override
    public String insert(RemittanceVoucher remittanceVoucher) {
        BaseModel.preInsert(remittanceVoucher);
        boolean result = remittanceVoucherWriteDao.insert(remittanceVoucher);
        if (result) {
            return remittanceVoucher.getId();
        }
        return null;
    }

    @Override
    public boolean update(RemittanceVoucher remittanceVoucher) {
        remittanceVoucher.setUpdateDate(new Date());
        return remittanceVoucherWriteDao.update(remittanceVoucher);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        if (StringUtils.isBlank(id))
            return false;

        return remittanceVoucherWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public RemittanceVoucher get(String id) {
        return remittanceVoucherReadDao.get(id);
    }

    @Override
    public List<RemittanceVoucher> listPage(RemittanceVoucher remittanceVoucher, Page page) {
        return remittanceVoucherReadDao.listPage(remittanceVoucher,page);
    }

    @Override
    public List<RemittanceVoucher> list(RemittanceVoucher remittanceVoucher) {
        return remittanceVoucherReadDao.listPage(remittanceVoucher,null);
    }

    @Override
    public List<RemittanceVoucher> batchList(Set<String> ids, RemittanceVoucher remittanceVoucher, Page page) {
        return null;
    }

    @Override
    public RemittanceVoucher findByPackageMemberId(String packageMemberId) {
        return remittanceVoucherReadDao.findByPackageMemberId(packageMemberId);
    }
}
